<?php
declare (strict_types = 1);

namespace app\common\model\Product;

use think\Model;
use app\common\model\Config;

/**
 * @mixin \think\Model
 */
class Type extends Model
{
    // 商品分类表
    protected $table = 'pre_product_type';

    protected $append = [
        'cover_cdn'   // 单图
    ];

    public function getCoverCdnAttr($value,$data) {
        $cover = is_file($data['cover']) ? $data['cover'] : '/static/home/res/images/cover/default.png';

        $cdn = Config::where(['key' => 'cdn'])->value('value');

        return $cdn.'/'.$cover;
    }
}
